// 登录模块
import { LoginAction } from '@/types/store'
import { Token } from '@/types/data'
import { getToken } from '@/utils/token'
// 登录模块：存储token(两个)
const initialState: Token = getToken() || {
  token: '', //用户令牌
  refresh_token: '', //用于刷新用户令牌
}

export const login = (state = initialState, action: LoginAction) => {
  // 执行存储token的命令
  if (action.type === 'token/login') {
    return action.payload
  }
  return state
}
